#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<vector>
#include<cstdio>
using namespace std;
int main()
{
	int N = 0; int cnt = 0;
	cin >> N;
	for (int i = 1; i <= N; ++i)
	{
		if (i % 10 == 1) ++cnt;
		if ((i / 10) % 10 == 1) ++cnt;
		if (((i / 10) / 10) % 10 == 1) ++cnt;
	}
	cout << cnt;
	return 0;
}